package com.li.springbootproject.spring.initstaticvariable;

import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2021年11月20日 16:24:00
 */
@Component
public class InitStaticVariableThree {

    private static final Logger logger = LoggerFactory.getLogger(InitStaticVariableThree.class);

    /**
     * 静态成员变量
     */
    public static RedissonClient redissonClientOne;

    /**
     * 注入 redissonClient
     */
    @Autowired
    private RedissonClient redissonClient;

    /**
     * 使用 PostConstruct 给静态成员变量赋值
     */
    @PostConstruct
    public void init() {
        redissonClientOne = redissonClient;
        logger.info(String.valueOf(redissonClient));
        logger.info(String.valueOf(redissonClientOne));
    }

}
